package com.citywithincity.utils.dataconvert;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.citywithincity.api.ApiBuildConfig;
import com.citywithincity.db.interfaces.IValueConvert;

public class ShortDate2UnixTime implements IValueConvert {

	@Override
	public Object convert(Object value) {
		if(value==null)return 0;
		try {
			Date date = new SimpleDateFormat(ApiBuildConfig.SHORT_DATE_FORMAT)
					.parse((String)value);
			return date.getTime() / 1000;
		} catch (ParseException e) {
			throw new RuntimeException(e);
		}
	}

}
